#!/bin/bash
Openssl_Version=openssl-$1
Dir=/application/update
Openssl_Dir=$Dir/${Openssl_Version} 
if [ $# -ne 1 ];then
	echo " usage: $0 <openssl version>"
	exit 1
fi
#configure and install openssl software
yum -y install gcc gcc-c++ perl per-core
cd /usr/local/src 
[ ! -f ${Openssl_Version}.tar.gz ] && wget https://www.openssl.org/source/old/1.1.0/${Openssl_Version}.tar.gz
[ ! -d $Dir ] && mkdir -p $Dir
tar xf ${Openssl_Version}.tar.gz && cd ${Openssl_Version} && ./config --prefix=${Openssl_Dir} && make && make install
mv /usr/bin/openssl /usr/bin/openssl.old 
mv /usr/include/openssl /usr/include/openssl.old
ln -sv ${Openssl_Dir} /application/update/openssl
ln -s /application/update/openssl/bin/openssl /usr/bin/openssl
ln -s /application/update/openssl/include/openssl /usr/include/openssl
echo "/application/update/openssl/lib/" >> /etc/ld.so.conf && ldconfig
cd /application/update/openssl/share/man
cp man1/* /usr/share/man/man1/
cp man3/* /usr/share/man/man3/
cp man5/* /usr/share/man/man5/
cp man7/* /usr/share/man/man7/


